package com.quick.api;

import com.quick.util.HttpStatus;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
@SuppressWarnings("unchecked")
public class Result<T> {
	
	private T result;
	private Integer code;
	private Object message;

	public static <T> T  ok(Object body) {
		return (T) Result.builder().result(body).code(HttpStatus.SUCCESS.getCode()).message(HttpStatus.SUCCESS.getMessage()).build();
	}

	public static <T> T fail(Integer code, String message) {
		return (T) Result.builder().code(code).message(message).build();
	}

	public static <T> T fail(String message) {
		return (T) Result.builder().code(HttpStatus.INTERNAL_SERVER_ERROR.getCode()).message(message).build();
	}

}
